package zjf.action;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import zjf.util.OperationUtil;
import zjf.util.StringUtil;
import zjf.vo.AdvancedUtil;
import zjf.vo.Sign;
import zjf.vo.WeixinContons;
import zjf.vo.WeixinOauth2Token;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;



public class CliffordAction extends BaseAction {
	private static final Log log = LogFactory
			.getLog(CliffordAction.class);
	public  String test() {
		resultData.put("datalist", "11");
		return SUCCESS;
	}
	/**
	 * 修改用户信息
	 * 
	 * @return
	 * @throws Exception
	 */
	public String updateUserInfo() {
		String openId=getCookieByName(getRequest(),"zjfmd_openId")!=null?getCookieByName(getRequest(),"zjfmd_openId").getValue():"";
		if(StringUtil.isNullOrEmpty(openId)){
			result=0;
			msg="登录超时，请重新登录";
			return SUCCESS;
		}	
//		openId="1";
		String userName="";
		String userMobile="";
		String userAddress="";
		if(parms!=null&&parms.get("userName")!=null){
			userName=parms.get("userName").toString();
		}
		if(parms!=null&&parms.get("userMobile")!=null){
			userMobile=parms.get("userMobile").toString();
		}
		if(parms!=null&&parms.get("userAddress")!=null){
			userAddress=parms.get("userAddress").toString();
		}
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "updateUserInfo");
		map.put("openId", openId);
		map.put("userName", userName);
		map.put("userAddress", userAddress);
		map.put("userMobile", userMobile);
		
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				JSONArray ary=JSON.parseArray(jsonpara.getString("dataList"));
				resultData.put("datalist", ary);
				resultData.put("size", ary!=null?ary.size():0);
			}else {
				result=0;
				if(jsonpara.getString("errmessage")!=null){
					msg=jsonpara.getString("errmessage");
				}else {
					msg="未获取到符合条件的数据";
				}
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 查询用户信息
	 * 
	 * @return
	 * @throws Exception
	 */
	public String queryUserInfo() {
		String openId=getCookieByName(getRequest(),"zjfmd_openId")!=null?getCookieByName(getRequest(),"zjfmd_openId").getValue():"";
		if(StringUtil.isNullOrEmpty(openId)){
			result=0;
			msg="登录超时，请重新登录";
			return SUCCESS;
		}	
//		openId="1";
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "queryUserInfo");
		map.put("openId", openId);
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				JSONArray ary=JSON.parseArray(jsonpara.getString("dataList"));
				resultData.put("datalist", ary);
				resultData.put("size", ary!=null?ary.size():0);
			}else {
				result=0;
				if(jsonpara.getString("errmessage")!=null){
					msg=jsonpara.getString("errmessage");
				}else {
					msg="未获取到符合条件的数据";
				}
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 查询广告详情
	 * 
	 * @return
	 * @throws Exception
	 */
	public String queryAdDetail() {
		String adId="";
		if(parms!=null&&parms.get("adId")!=null){
			adId=parms.get("adId").toString();
		}
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "queryADByID");
		map.put("adId",adId);
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				JSONArray ary=JSON.parseArray(jsonpara.getString("dataList"));
				resultData.put("datalist", ary);
				resultData.put("size", ary!=null?ary.size():0);
			}else {
				result=0;
				if(jsonpara.getString("errmessage")!=null){
					msg=jsonpara.getString("errmessage");
				}else {
					msg="未获取到符合条件的数据";
				}
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 查询印象标签留言
	 * 
	 * @return
	 * @throws Exception
	 */
	public String queryMessage() {
		String tagId="";
		if(parms!=null&&parms.get("tagId")!=null){
			tagId=parms.get("tagId").toString();
		}
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "queryMessage");
		map.put("tagId",tagId);
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				JSONArray ary=JSON.parseArray(jsonpara.getString("dataList"));
				resultData.put("datalist", ary);
				resultData.put("size", ary!=null?ary.size():0);
			}else {
				result=0;
				if(jsonpara.getString("errmessage")!=null){
					msg=jsonpara.getString("errmessage");
				}else {
					msg="未获取到符合条件的数据";
				}
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 查询印象标签
	 * 
	 * @return
	 * @throws Exception
	 */
	public String queryLable() {
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "queryLable");
	
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				JSONArray ary=JSON.parseArray(jsonpara.getString("dataList"));
				resultData.put("datalist", ary);
				resultData.put("size", ary!=null?ary.size():0);
			}else {
				result=0;
				if(jsonpara.getString("errmessage")!=null){
					msg=jsonpara.getString("errmessage");
				}else {
					msg="未获取到符合条件的数据";
				}
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 查询我的祈福进度
	 * 
	 * @return
	 * @throws Exception
	 */
	public String queryCliffordReocrdListByOpenId() {
		String openId="";
		String cliffordId="";
//		if(parms!=null&&parms.get("openId")!=null){
//			openId=parms.get("openId").toString();
//		}
		openId=getCookieByName(getRequest(),"zjfmd_openId")!=null?getCookieByName(getRequest(),"zjfmd_openId").getValue():"";
		if(StringUtil.isNullOrEmpty(openId)){
			result=0;
			msg="登录超时，请重新登录";
			return SUCCESS;
		}
		if(parms!=null&&parms.get("cliffordId")!=null){
			cliffordId=parms.get("cliffordId").toString();
		}
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "queryCliffordReocrdListByOpenId");
		map.put("openId", openId);
		map.put("cliffordId",cliffordId);
		map.put("tag",1);
		
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				JSONArray ary=JSON.parseArray(jsonpara.getString("dataList"));
				JSONObject dataBean=JSON.parseObject(jsonpara.getString("dataBean"));
//				JSONArray dataBean=JSON.parseArray(jsonpara.getString("dataBean"));
				JSONObject dataBeanUser=JSON.parseObject(jsonpara.getString("dataBeanUser"));
				resultData.put("dataBean",dataBean);
				resultData.put("dataBeanUser",dataBeanUser);
				resultData.put("dataBeansize",dataBean!=null&&dataBean.size()>0?1:0);
				resultData.put("datalist", ary);
				resultData.put("size", ary!=null?ary.size():0);
			}else {
				result=0;
				if(jsonpara.getString("errmessage")!=null){
					msg=jsonpara.getString("errmessage");
				}else {
					msg="未获取到符合条件的数据";
				}
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 查询我的聚福记录列表
	 * 
	 * @return
	 * @throws Exception
	 */
	public String queryMyCliffordRecordList() {
		String openId="";
		String status="";
//		if(parms!=null&&parms.get("openId")!=null){
//			openId=parms.get("openId").toString();
//		}
		openId=getCookieByName(getRequest(),"zjfmd_openId")!=null?getCookieByName(getRequest(),"zjfmd_openId").getValue():"";
		if(StringUtil.isNullOrEmpty(openId)){
			result=0;
			msg="登录超时，请重新登录";
			return SUCCESS;
		}
		if(parms!=null&&parms.get("status")!=null){
			status=parms.get("status").toString();
		}
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "queryMyCliffordRecordList");
		map.put("openId", openId);
		map.put("status",status);
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				JSONArray ary=JSON.parseArray(jsonpara.getString("dataList"));
				resultData.put("datalist", ary);
				resultData.put("size", ary!=null?ary.size():0);
			}else {
				result=0;
				if(jsonpara.getString("errmessage")!=null){
					msg=jsonpara.getString("errmessage");
				}else {
					msg="未获取到符合条件的数据";
				}
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 查询我的祈福列表
	 * 
	 * @return
	 * @throws Exception
	 */
	public String queryMyCliffordList() {
		String openId="";
		String status="";
//		if(parms!=null&&parms.get("openId")!=null){
//			openId=parms.get("openId").toString();
//		}
		openId=getCookieByName(getRequest(),"zjfmd_openId")!=null?getCookieByName(getRequest(),"zjfmd_openId").getValue():"";
		if(StringUtil.isNullOrEmpty(openId)){
			result=0;
			msg="登录超时，请重新登录";
			return SUCCESS;
		}
		if(parms!=null&&parms.get("status")!=null){
			status=parms.get("status").toString();
		}
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "queryCliffordListByOpenId");
		map.put("openId", openId);
		map.put("status",status);
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				JSONArray ary=JSON.parseArray(jsonpara.getString("dataList"));
				resultData.put("datalist", ary);
				resultData.put("size", ary!=null?ary.size():0);
			}else {
				result=0;
				if(jsonpara.getString("errmessage")!=null){
					msg=jsonpara.getString("errmessage");
				}else {
					msg="未获取到符合条件的数据";
				}
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 开始祈福详情
	 * 
	 * @return
	 * @throws Exception
	 */
	public String startClifford() {
		String goodsId="";
		String openId="";
		String owner_price="";
		String cliffordName="";
		if(parms!=null&&parms.get("goodsId")!=null){
			goodsId=parms.get("goodsId").toString();
		}
//		if(parms!=null&&parms.get("openId")!=null){
//			openId=parms.get("openId").toString();
//		}
		openId=getCookieByName(getRequest(),"zjfmd_openId")!=null?getCookieByName(getRequest(),"zjfmd_openId").getValue():"";
		if(StringUtil.isNullOrEmpty(openId)){
			result=0;
			msg="登录超时，请重新登录";
			return SUCCESS;
		}
		if(parms!=null&&parms.get("owner_price")!=null){
			owner_price=parms.get("owner_price").toString();
		}
		if(parms!=null&&parms.get("cliffordName")!=null){
			cliffordName=parms.get("cliffordName").toString();
		}
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "saveCliffordInfo");
		map.put("goodsId", goodsId);
		map.put("openId", openId);
		map.put("owner_price",owner_price);
		map.put("cliffordName", cliffordName);
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				resultData.put("cliffordId", jsonpara.getString("cliffordId"));
			}else if(jsonpara.getIntValue("result")==2){
				result=2;
				resultData.put("cliffordId", jsonpara.getString("cliffordId"));
				msg=jsonpara.getString("errmessage");
			}else {
				result=0;
				if(jsonpara.getString("errmessage")!=null){
					msg=jsonpara.getString("errmessage");
				}else {
					msg="未获取到符合条件的数据";
				}
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 查询祈福记录详情
	 * 
	 * @return
	 * @throws Exception
	 */
	public String queryCliffordDetailByCliffordId() {
		String cliffordId="";
		if(parms!=null&&parms.get("cliffordId")!=null){
			cliffordId=parms.get("cliffordId").toString();
		}
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "queryCliffordDetail");
		map.put("cliffordId", cliffordId);
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				resultData.put("datalist", JSON.parseObject(jsonpara.getString("zjfClifford")));
			}else {
				result=0;
				msg="未获取到符合条件的数据";
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 查询祈福详情
	 * 
	 * @return
	 * @throws Exception
	 */
	public String queryCliffordDetail() {
		String goodsId="";
		if(parms!=null&&parms.get("goodsId")!=null){
			goodsId=parms.get("goodsId").toString();
		}
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "queryCliffordGoodsById");
		map.put("goodsId", goodsId);
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				JSONArray ary=JSON.parseArray(jsonpara.getString("dataList"));
				//			for(Object o:ary){
				//				JSONObject j = JSONObject.parseObject(o.toString());
				//				System.out.println(j.getString("zjfGood"));
				//				System.out.println(j.getString("zjfGoodsType"));
				//			}
				resultData.put("datalist", ary);
				resultData.put("size", ary!=null?ary.size():0);
			}else {
				result=0;
				msg="未获取到符合条件的数据";
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 查询祈福列表
	 * 
	 * @return
	 * @throws Exception
	 */
	public String queryCliffordList() {
		String cliffordpage="";
		if(parms!=null&&parms.get("cliffordpage")!=null){
			cliffordpage=parms.get("cliffordpage").toString();
		}
		
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "queryCliffordGoodsList");
		map.put("page", cliffordpage);
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				JSONArray ary=JSON.parseArray(jsonpara.getString("dataList"));
				//				for(Object o:ary){
				//					JSONObject j = JSONObject.parseObject(o.toString());
				//					System.out.println(j.getString("zjfGood"));
				//					System.out.println(j.getString("zjfGoodsType"));
				//				}
				resultData.put("datalist", ary);
				resultData.put("size", ary!=null?ary.size():0);
			}else {
				result=0;
				msg="未获取到符合条件的数据";
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 分类查询祈福列表
	 * 
	 * @return
	 * @throws Exception
	 */
	public String queryCliffordListByClass() {
		String classId="";
		if(parms!=null&&parms.get("classId")!=null){
			classId=parms.get("classId").toString();
		}
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "queryCliffordGoodsListByClass");
		map.put("class_type_id", classId);
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				JSONArray ary=JSON.parseArray(jsonpara.getString("dataList"));
				resultData.put("datalist", ary);
				resultData.put("size", ary!=null?ary.size():0);
			}else {
				result=0;
				msg="未获取到符合条件的数据";
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 查询推荐列表
	 * 
	 * @return
	 * @throws Exception
	 */
	public String queryRecommendList() {
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "queryRecommendGoodsList");
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				JSONArray ary=JSON.parseArray(jsonpara.getString("dataList"));
				//				for(Object o:ary){
				//					JSONObject j = JSONObject.parseObject(o.toString());
				//					System.out.println(j.getString("zjfGood"));
				//					System.out.println(j.getString("zjfGoodsType"));
				//				}
				resultData.put("datalist", ary);
				resultData.put("size", ary!=null?ary.size():0);
			}else {
				result=0;
				msg="未获取到符合条件的数据";
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 查询类型列表
	 * 
	 * @return
	 * @throws Exception
	 */
	public String queryTypeList() {
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "queryGoodsType");
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				JSONArray ary=JSON.parseArray(jsonpara.getString("dataList"));
				//				for(Object o:ary){
				//					JSONObject j = JSONObject.parseObject(o.toString());
				//					System.out.println(j.getString("zjfGood"));
				//					System.out.println(j.getString("zjfGoodsType"));
				//				}
				resultData.put("datalist", ary);
				resultData.put("size", ary!=null?ary.size():0);
			}else {
				result=0;
				msg="未获取到符合条件的数据";
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 查询分类列表
	 * 
	 * @return
	 * @throws Exception
	 */
	public String queryClassList() {
		String typeId="";
		if(parms!=null&&parms.get("typeId")!=null){
			typeId=parms.get("typeId").toString();
		}
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "queryGoodsClass");
		map.put("class_type_id", typeId);
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				JSONArray ary=JSON.parseArray(jsonpara.getString("dataList"));
				resultData.put("datalist", ary);
				resultData.put("size", ary!=null?ary.size():0);
			}else {
				result=0;
				msg="未获取到符合条件的数据";
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 查询广告列表
	 * 
	 * @return
	 * @throws Exception
	 */
	public String queryAdList() {
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "queryADList");
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				JSONArray ary=JSON.parseArray(jsonpara.getString("dataList"));
				//				for(Object o:ary){
				//					JSONObject j = JSONObject.parseObject(o.toString());
				//					System.out.println(j.getString("zjfGood"));
				//					System.out.println(j.getString("zjfGoodsType"));
				//				}
				resultData.put("datalist", ary);
				resultData.put("size", ary!=null?ary.size():0);
			}else {
				result=0;
				msg="未获取到符合条件的数据";
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 查询众筹活动列表
	 * 
	 * @return
	 * @throws Exception
	 */
	public String queryActivityList() {
		String activitypage="";
		if(parms!=null&&parms.get("activitypage")!=null){
			activitypage=parms.get("activitypage").toString();
		}
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "queryActivityList");
		map.put("page", activitypage);
		
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				JSONArray ary=JSON.parseArray(jsonpara.getString("dataList"));
				resultData.put("datalist", ary);
				resultData.put("size", ary!=null?ary.size():0);
			}else {
				result=0;
				msg="未获取到符合条件的数据";
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 查询众筹活动详情
	 * 
	 * @return
	 * @throws Exception
	 */
	public String queryActivityDetail() {
		String activityId="";
		if(parms!=null&&parms.get("activityId")!=null){
			activityId=parms.get("activityId").toString();
		}
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "queryActivityByID");
		map.put("activityId", activityId);
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				JSONArray ary=JSON.parseArray(jsonpara.getString("dataList"));
				resultData.put("datalist", ary);
				resultData.put("size", ary!=null?ary.size():0);
			}else {
				result=0;
				msg="未获取到符合条件的数据";
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 查询众筹活动详情 ----麦道
	 * 
	 * @return
	 * @throws Exception
	 */
	public String queryActivityDetailCake() {
		String openId="";
		openId=getCookieByName(getRequest(),"zjfmd_openId")!=null?getCookieByName(getRequest(),"zjfmd_openId").getValue():"";
		if(StringUtil.isNullOrEmpty(openId)){
			result=0;
			msg="登录超时，请重新登录";
			return SUCCESS;
		}
//		openId="okvZzwpjvb4oLklZ89mxnviYwiOM";
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "queryActivityByCake");
		map.put("openId", openId);
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				JSONArray ary=JSON.parseArray(jsonpara.getString("dataList"));
				resultData.put("datalist", ary);
				resultData.put("size", ary!=null?ary.size():0);
			}else {
				result=0;
				msg="未获取到符合条件的数据";
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 查询我参加的众筹活动
	 * 
	 * @return
	 * @throws Exception
	 */
	public String queryMyActivityList() {
		String openId="";
		String status="";
//		if(parms!=null&&parms.get("openId")!=null){
//			openId=parms.get("openId").toString();
//		}
		openId=getCookieByName(getRequest(),"zjfmd_openId")!=null?getCookieByName(getRequest(),"zjfmd_openId").getValue():"";
		if(StringUtil.isNullOrEmpty(openId)){
			result=0;
			msg="登录超时，请重新登录";
			return SUCCESS;
		}
		if(parms!=null&&parms.get("status")!=null){
			status=parms.get("status").toString();
		}
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "queryActivityRecordListByOpenId");
		map.put("openId", openId);
		map.put("status", status);
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				JSONArray ary=JSON.parseArray(jsonpara.getString("dataList"));
				resultData.put("datalist", ary);
				resultData.put("size", ary!=null?ary.size():0);
			}else {
				result=0;
				msg="未获取到符合条件的数据";
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 参加活动 
	 * 
	 * @return
	 * @throws Exception
	 */
	public String joinActivity() {
		String activity_id="";
		String openId="";
		String money="";
		String order_num="";
		if(parms!=null&&parms.get("activity_id")!=null){
			activity_id=parms.get("activity_id").toString();
		}
//		if(parms!=null&&parms.get("openId")!=null){
//			openId=parms.get("openId").toString();
//		}
		openId=getCookieByName(getRequest(),"zjfmd_openId")!=null?getCookieByName(getRequest(),"zjfmd_openId").getValue():"";
		if(StringUtil.isNullOrEmpty(openId)){
			result=0;
			msg="登录超时，请重新登录";
			return SUCCESS;
		}
		if(parms!=null&&parms.get("money")!=null){
			money=parms.get("money").toString();
		}
//		order_num="sad2324r35t";
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "saveActivityRecord");
		map.put("activity_id", activity_id);
		map.put("openId", openId);
		map.put("money",money);
		map.put("order_num", order_num);
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
			}else {
				result=0;
				if(jsonpara.getString("errmessage")!=null){
					msg=jsonpara.getString("errmessage");
				}else {
					msg="未获取到符合条件的数据";
				}
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 保存地址
	 * 
	 * @return
	 * @throws Exception
	 */
	public String saveAddress() {
		String openId="";
		String userName="";
		String mobile="";
		String address="";
		if(parms!=null&&parms.get("userName")!=null){
			userName=parms.get("userName").toString();
		}
//		if(parms!=null&&parms.get("openId")!=null){
//			openId=parms.get("openId").toString();
//		}
		openId=getCookieByName(getRequest(),"zjfmd_openId")!=null?getCookieByName(getRequest(),"zjfmd_openId").getValue():"";
		if(StringUtil.isNullOrEmpty(openId)){
			result=0;
			msg="登录超时，请重新登录";
			return SUCCESS;
		}
		if(parms!=null&&parms.get("mobile")!=null){
			mobile=parms.get("mobile").toString();
		}
		if(parms!=null&&parms.get("address")!=null){
			address=parms.get("address").toString();
		}
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "saveAddress");
		map.put("openId", openId);
		map.put("user_name", userName);
		map.put("user_address_mobile",mobile);
		map.put("user_address", address);
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
			}else {
				result=0;
				if(jsonpara.getString("errmessage")!=null){
					msg=jsonpara.getString("errmessage");
				}else {
					msg="保存地址失败";
				}
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 获取地址列表
	 * 
	 * @return
	 * @throws Exception
	 */
	public String queryAddressList() {
		String openId="";
//		if(parms!=null&&parms.get("openId")!=null){
//			openId=parms.get("openId").toString();
//		}
		openId=getCookieByName(getRequest(),"zjfmd_openId")!=null?getCookieByName(getRequest(),"zjfmd_openId").getValue():"";
		if(StringUtil.isNullOrEmpty(openId)){
			result=0;
			msg="登录超时，请重新登录";
			return SUCCESS;
		}
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("func_name", "queryAddressList");
		map.put("openId", openId);
		String returnStr=OperationUtil.result(map);
		JSONObject jsonpara = JSONObject.parseObject(returnStr);
		if(jsonpara!=null&&jsonpara.size()>0){
			if(jsonpara.getIntValue("result")==0){
				result=1;
				JSONArray ary=JSON.parseArray(jsonpara.getString("dataList"));
				resultData.put("datalist", ary);
				resultData.put("size", ary!=null?ary.size():0);
			}else {
				result=0;
				msg="未获取到符合条件的数据";
			}
		}else {
			result=0;
			msg="网络故障";
		}
		return SUCCESS;
	}
	/**
	 * 获取微信配置参数
	 * 
	 * @return
	 * @throws Exception
	 */
	public String makeWeixinConfig() {
		try {
			msg="true";
			WeixinOauth2Token weixinOauth2Token = AdvancedUtil.getAccessToken(WeixinContons.APPID,WeixinContons.APPSECRET);
			String accessToken = weixinOauth2Token.getAccessToken();
			String jsapi_ticket = AdvancedUtil.getJsapiTicket(accessToken);
			// 注意 URL 一定要动态获取，不能 hardcode
			String url = "";
			if(parms!=null){
				url=parms.get("url");
			}
			Map<String, String> ret = Sign.sign(jsapi_ticket, url);
			ret.put("weixin_appId", WeixinContons.APPID);
			resultData.put("config", ret);
			for (Map.Entry entry : ret.entrySet()) {
				System.out.println(entry.getKey() + ", " + entry.getValue());
			}
		} catch (Exception e) {
			e.printStackTrace();
			log.debug("解析命令出错: " + e.getMessage());
			msg="获取微信配置出错!";
		}
		return SUCCESS;
	}
	
	public Map<String, Object> getResultData() {
		return resultData;
	}
	public void setResultData(Map<String, Object> resultData) {
		this.resultData = resultData;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public int getResult() {
		return result;
	}
	public void setResult(int result) {
		this.result = result;
	}
}
